package com.lin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

import java.io.IOException;
import java.util.Properties;

@Configuration
@ComponentScan({"com.lin.controller", "com.lin.exceptionHandler"})
@EnableWebMvc
public class SpringMVCConfig {

    // 简单异常处理器  --SpringMVC内置  SimpleMappingExceptionResolver
    /*@Bean
    public SimpleMappingExceptionResolver simpleMappingExceptionResolver() throws IOException {
        SimpleMappingExceptionResolver simpleMappingExceptionResolver = new SimpleMappingExceptionResolver();
        // 默认异常处理页面, 只要出现异常就跳转这个页面
        simpleMappingExceptionResolver.setDefaultErrorView("/static/error1.html");

        // 指定明确的异常由哪个页面处理
        Properties properties = new Properties();
        properties.load(this.getClass().getClassLoader().getResourceAsStream("exception.properties"));
        simpleMappingExceptionResolver.setExceptionMappings(properties);
        return simpleMappingExceptionResolver;
    }*/

}
